package MONITORING::DB::ORACLE::ALERT_LOG;

#################################################################
# $LastChangedDate: 2013-11-25 15:03:06 +0000 (Mon, 25 Nov 2013) $
# $LastChangedRevision: 22 $
# $LastChangedBy: aswod_83@gmx.net $
#################################################################

use strict;
use base qw(moniCA::DBH::Oracle);
use XML::Simple;
use Data::Dumper;

#-------------------------------------------------------------------------------
sub Run {

#-------------------------------------------------------------------------------
# Description:  Creating/Updating RRD File
# Input Parms:	Tablespace_Name
# Output Parms: None
#-------------------------------------------------------------------------------
    my $self      = shift;
    my $cnf       = $self->GetCNF();
    my $logger    = $self->GetLogger();
    my $statefile = $self->TmpDir() . '/' . $self->Plug() . '.xml';

    $self->ConnectDB(@_);

    $self->find_err( $self->_get_background_dump_dest()
          . "/alert_"
          . $self->_get_instance_name()
          . ".log" );
}

#-------------------------------------------------------------------------------
sub _get_instance_name {

#-------------------------------------------------------------------------------
# Description:  Creating/Updating RRD File
# Input Parms:	Tablespace_Name
# Output Parms: None
#-------------------------------------------------------------------------------
    my $self = shift;
    my $stmt = q{
						select instance_name from v$instance
                      };
    my $sth = $self->{DBH}->prepare($stmt);
    $sth->execute();
    my $row = $sth->fetchrow_hashref;
    $sth->finish;
    return $row->{INSTANCE_NAME};
}

#-------------------------------------------------------------------------------
sub _get_background_dump_dest {

#-------------------------------------------------------------------------------
# Description:  Creating/Updating RRD File
# Input Parms:	Tablespace_Name
# Output Parms: None
#-------------------------------------------------------------------------------
    my $self = shift;
    my $stmt = q{
               			SELECT value 
						FROM   v$parameter 
						WHERE  name = 'background_dump_dest'
                        };
    my $sth = $self->{DBH}->prepare($stmt);
    $sth->execute();
    my $row = $sth->fetchrow_hashref;
    $sth->finish;

    return $row->{VALUE};
}
1;
__END__
 
=pod
 
=head1 NAME
 
ALERT_LOG.pm - monitors oracle alert log 
 
=head1 SYNOPSIS 
 
=head1 DESCRIPTION
 
=head1 PREREQUISITES
 
The follwing modules needs to be installed:
 
C<Log::Log4perl>
C<XML::Simple>
C<base qw(moniCA::DBH::Oracle)>
 
=head1 CONFIGURATION FILE
 
  By default
 
=head2 EXAMPLES
 
=head3 example of configuation file

Modul 	    MONITORING::DB::ORACLE::ALERT_LOG
Logger		tbs-xe
LogLevel	DEBUG

<DBConnect>
	ConnectString	dbi:Oracle:SID=XE;HOST=localhost;port=1521
	dbuser		MONICA
	dbpw		monica
	description 	lokale oracle xe Testdatenbank
</DBConnect>

<blacklist>
BL1	= error
BL2	= ORA-
</blacklist>

<whitelist>
WL1 = 	ORA-1109
WL2 =	ORA-00313
</whitelist>

=cut
